package com.jp.knowledge.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.jp.knowledge.R;
import com.jp.knowledge.adapter.skill.PositionKnolegeContentAdapter;
import com.jp.knowledge.model.PositionKnowlegeMode;
import com.jp.knowledge.my.base.RecycleVAdapter;
import com.jp.knowledge.my.base.RecycleVHolder;
import com.jp.knowledge.view.JpRecycleView;
import com.jp.knowledge.view.SkillContentView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by 528787067@qq.com on 2017/6/24.
 */

public class PositionKnowledgeAdapter extends RecycleVAdapter<PositionKnowlegeMode.ListBeanX> {
	public PositionKnowledgeAdapter(Context context, @NonNull List<PositionKnowlegeMode.ListBeanX> list) {
		super(context, list);
	}

	@Override
	public int getLayoutId(int viewType) {
		return R.layout.skill_content_view;
	}

	@Override
	public void onBind(RecycleVHolder holder, int position) {
		holder.get(R.id.line).setVisibility(position == 0 ? View.GONE : View.VISIBLE);
		holder.setTextView(R.id.skill_content_title, getData(position).getName());
		JpRecycleView recyclerView = holder.get(R.id.skill_content_view);
		if(recyclerView.getLayoutManager() == null)
			recyclerView.setLayoutManager(new GridLayoutManager(mContext, 3){
				@Override
				public boolean canScrollVertically() {
					return false;
				}
				@Override
				public boolean canScrollHorizontally() {
					return false;
				}
			});
		recyclerView.setHasFixedSize(true);
		PositionKnolegeContentAdapter adapter = (PositionKnolegeContentAdapter) recyclerView.getAdapter();
		if(adapter == null)
			recyclerView.setAdapter(new PositionKnolegeContentAdapter(mContext, getData(position).getList()));
		else
			adapter.updateAdapter(getData(position).getList());
	}
}
